home *** CD-ROM | disk | FTP | other *** search
- {*********************************************************}
- {* HTMLVIEW.PAS *}
- {* Copyright (c) 1995 by *}
- {* L. David Baldwin *}
- {* All rights reserved. *}
- {*********************************************************}
-
- unit Htmlview;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, ExtCtrls, ReadHTML, HTMLSubs;
-
- type
- THotSpotEvent = procedure(Sender: TObject; const SRC: string) of Object;
- THotSpotClickEvent = procedure(Sender: TObject; const SRC: string;
- var Handled: boolean) of Object;
-
- TThumbScrollBox = class(TScrollBox)
- private
- procedure WMVScroll(var Message: TWMVScroll); message WM_VScroll;
- end;
-
- THTMLViewer = class(TWinControl)
- private
- { Private declarations }
- FTitle: PString;
- FURL: PString;
- FBase: PString;
- FCurrentFile: PString;
- FSectionList: TSectionList;
- FNameList: TStringList;
- FOnHotSpotCovered: THotSpotEvent;
- FOnHotSpotClick: THotSpotClickEvent;
- FOnBitmapRequest: TGetBitmapEvent;
- FOnHistoryChange: TNotifyEvent;
- FHistory: TStrings;
- FHistoryIndex: integer;
- FHistoryMaxCount: integer;
- procedure ScrollResize(Sender: TObject);
- procedure SetViewImages(Value: boolean);
- function GetViewImages: boolean;
- procedure SetColor(Value: TColor);
- function GetColor: TColor;
- function GetBase: string;
- function GetFURL: string;
- function GetTitle: string;
- function GetCurrentFile: string;
- procedure SetBorderStyle(Value: TBorderStyle);
- function GetBorderStyle: TBorderStyle;
- function GetPosition: LongInt;
- procedure SetPosition(Value: LongInt);
- function GetScrollPos: integer;
- procedure SetScrollPos(Value: integer);
- function GetScrollBarRange: integer;
- procedure SetHistoryIndex(Value: integer);
- procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
- procedure SetupAndLogic;
- protected
- { Protected declarations }
- ScrollBox: TThumbScrollBox;
- PaintBox: TPaintBox;
- function DoLogic: integer;
- function GetURL(X, Y: integer; var URL: OpenString): boolean;
- procedure KeyDown(var Key: Word; Shift: TShiftState); override;
- function GetPalette: HPALETTE; override;
- procedure HTMLPaint(Sender: TObject); virtual;
- procedure HTMLMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer); virtual;
- procedure HTMLMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer); virtual;
- procedure URLAction; virtual;
- function HotSpotClickHandled: boolean; dynamic;
- procedure BumpHistory(const FileName: string; OldPos: LongInt);
- procedure LoadFile(const FileName: string);
-
- public
- { Public declarations }
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function HTMLExpandFilename(const Filename: string): string; virtual;
- procedure LoadFromFile(const FileName: string);
- procedure LoadStrings(Strings: TStrings);
- procedure LoadFromBuffer(Buffer: PChar; BufSize: LongInt);
- function PositionTo(Dest: string): boolean;
- property DocumentTitle: string read GetTitle;
- property URL: string read GetFURL;
- property Base: string read GetBase;
- property Position: LongInt read GetPosition write SetPosition;
- property VScrollBarPosition: integer read GetScrollPos write SetScrollPos;
- property VScrollBarRange: integer read GetScrollBarRange;
- property CurrentFile: string read GetCurrentFile;
- property History: TStrings read FHistory;
- property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
-
- published
- { Published declarations }
- property OnHotSpotCovered: THotSpotEvent read FOnHotSpotCovered
- write FOnHotSpotCovered;
- property OnHotSpotClick: THotSpotClickEvent read FOnHotSpotClick
- write FOnHotSpotClick;
- property OnBitmapRequest: TGetBitmapEvent read FOnBitmapRequest
- write FOnBitmapRequest;
- property OnHistoryChange: TNotifyEvent read FOnHistoryChange
- write FOnHistoryChange;
- property ViewImages: boolean read GetViewImages write SetViewImages;
- property TabStop;
- property TabOrder;
- property Align;
- property Name;
- property Tag;
- property Height default 150;
- property Width default 150;
- property Color: TColor read GetColor write SetColor default clBtnFace;
- property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;
- property Visible;
- property HistoryMaxCount: integer read FHistoryMaxCount write FHistoryMaxCount;
- end;
-
- procedure Register;
-
- implementation
-
-